#!/usr/bin/python

import sys
import operator
import subprocess

seq=''
if (sys.arg > 0):
	seq="-%i" % int(sys.argv[0])

def read(filename):
	f=open(filename,'r')

	values=[];
	for str in f:
		values.append(float(str));
	return values

out = open('data', 'w')

kind = ("modelNN", "FingerNN",  "FingerKNN", "modelKNN")
values=dict()
total=dict()
acc = dict()
for k in kind:
	values[k]=read("score%s%s.txt" % (k,seq))
	total[k] = sum(values[k])
	acc[k] = 0

for i in range(0, len(values["modelNN"])):
	str = ''
	for k in kind:
		str = str + "%f %f " % (values[k][i], (acc[k] / total[k]));
		acc[k] = acc[k] + values[k][i]
	print str
	out.write("%s\n" % str)

plot="""set key bottom; set grid ytics; plot [0:60] "data" using 1:2 title "modelNN", "data" using 3:4 title "fingerPrintingNN", "data" using 5:6 title "fingerPrintingKNN", "data" using 7:8 title "modelKNN"; pause -1""" 
subprocess.call(["gnuplot -e '%s'" % plot],shell=True)
